﻿// console client to test web service

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

using ColourAppClient.ColourAppServiceReference;    // service reference 

namespace ColourAppClient
{
    class Client
    {
        // private fields
        private string hairColour;
        private string eyeColour;
              
        // read only property for Hair Colour
        public string HairColour 
        {
            get
            {
                return hairColour;
            }
        }

        // read only property for Eye Colour
        public string EyeColour
        {
            get
            {
                return eyeColour;
            }
        }

        // lists of hair colours, eye colours for user to select from
        // static because shared between all users
        private static ArrayList hairColourOptions;
        private static ArrayList eyeColourOptions;
        
        // constructor to initialize array lists
        public Client()
        {
            hairColourOptions = new ArrayList() { "Ash Blonde", "Golden Blonde", "Strawberry Blonde" ,"Light Brown", "Medium Brown", "Ash Brown", "Dark Brown", "Black", "Red", "Auburn", "Dark Auburn" };
            eyeColourOptions = new ArrayList() { "Bright Blue", "Blue", "Dark Blue", "Blue/Grey", "Bright Blue/Green", "Blue/Green", "Bright Green", "Green", "Bright Hazel" , "Hazel", "Brown", "Dark Brown", "Steel Grey" };
        }

        // method to prompt user to select hair colour, return type is int for index position in to 2D array of results 
        public int SelectHairColour()
        {
            Console.WriteLine("HAIR COLOUR OPTIONS:");
            foreach (string colour in hairColourOptions)    // print out list of hair colour options
            {
                Console.WriteLine(colour.ToString());
            }
            Console.WriteLine();        // line space
            Console.Write("Please enter your hair colour: ");
            hairColour = Console.ReadLine();      // assign user input to hairColour
            int hairIndex = hairColourOptions.IndexOf(hairColour);  //get index value of the hair colour selected
            return hairIndex;
        }

        // method for user to select eye colour, return type is int for index position in to 2D array of results
        public int SelectEyeColour()
        {
            Console.WriteLine("EYE COLOUR OPTIONS:");
            foreach (string colour in eyeColourOptions)    // print out list of eye colour options
            {
                Console.WriteLine(colour.ToString());
            }
            Console.WriteLine();        // line space
            Console.Write("Please enter your eye colour: ");
            eyeColour = Console.ReadLine();             // assign user input to eyeColour
            int eyeIndex = eyeColourOptions.IndexOf(eyeColour);  //get index value of the eye colour selected
            return eyeIndex;
        }      
        
        static void Main()
        {
            try 
            {
                // prompt user to select hair and eye colour
                Client user = new Client();
                int hairIndex = user.SelectHairColour();
                Console.WriteLine("\n");
                int eyeIndex = user.SelectEyeColour();

                // create proxy
                ColourTypeServiceClient client = new ColourTypeServiceClient();
                
                // web service call passing in 2 parameters of hair colour index and eye colour index
                Console.WriteLine("Your Dominant Characteristic is: " + client.DetermineDominantCharacteristic(hairIndex, eyeIndex));
            }
            catch(Exception e)
            {
                Console.WriteLine(e);
            }
        }
    }
}
